Skip to content

test(fastapi): ServeCommand tests via Cleo CommandTester#123

Merged
bedus-creation merged 5 commits into
mainfrom
task/revert-serve-command-use-cleo-tester
Jun 13, 2026
Merged

test(fastapi): ServeCommand tests via Cleo CommandTester#123
bedus-creation merged 5 commits into
mainfrom
task/revert-serve-command-use-cleo-tester

Conversation

@bedus-creation

Copy link
Copy Markdown
Contributor

Summary

  • Keeps the f9f533c5 serve command code intact (resolve_option / resolve_url approach)
  • Adds tests/fastapi/test_serve_command.py with 18 test cases driven entirely through Cleo's CommandTester — no ad-hoc option stubbing
  • uvicorn.run, Config.get, and env are patched so tests run without a live app or network

Test coverage

Class What's tested
TestServeCommandDefaults Exit code, uvicorn called, default host/port in output, ws kwarg
TestCliOptions --host / --port in output and forwarded to uvicorn
TestConfigOptions Config-driven host, port, and app_url behaviour
TestAppFound App label in output, factory=True, app string kwarg
TestAppNotFound No factory kwarg, reload=False

Test plan

  • uv run pytest tests/fastapi/test_serve_command.py -v → 18 passed

🤖 Generated with Claude Code

bedus-creation and others added 5 commits June 13, 2026 10:49
Drive the serve command end-to-end via Cleo's CommandTester — no manual
option stubbing.  18 cases cover defaults, CLI --host/--port overrides,
config-driven host/port, app-found vs not-found paths, and uvicorn kwargs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e in ServeCommand

Add a new standalone `value()` helper to the environment module that casts
an already-resolved value to the appropriate Python type (int, bool, None,
str) without performing any os.getenv lookup.

Fix `ServeCommand.resolve_option()` which was calling `env(value)` on an
already-resolved host/port string — `env()` treats its first argument as
an env-var name, so it silently dropped the resolved value. Replace the
call with `cast_value()` (the new `value()` function) so host/port are
cast correctly without a spurious os.getenv lookup.

Also update test_serve_command.py to remove the now-unnecessary `env`
identity-patch workaround that masked the bug.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bedus-creation bedus-creation merged commit 3755325 into main Jun 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant